<template>
  <div class="publish">
    <el-card>
      <template #header>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="'/home'">首页</el-breadcrumb-item>
          <el-breadcrumb-item>发布文章</el-breadcrumb-item>
        </el-breadcrumb>
      </template>
      <el-form label-width="100px">
        <!-- 标题组件 -->
        <el-form-item label="标题：">
          <el-input placeholder="请输入文章标题"></el-input>
        </el-form-item>
        <!-- 频道组件 -->
        <el-form-item label="频道：">
          <el-select placeholder="请选择">
            <el-option> </el-option>
          </el-select>
        </el-form-item>
        <!-- 封面单选按钮组件 -->
        <el-form-item label="封面：">
          <el-radio-group v-model="form.status">
            <el-radio :label="0">单图</el-radio>
            <el-radio :label="1">三图</el-radio>
            <el-radio :label="2">无图</el-radio>
            <el-radio :label="3">自动</el-radio>
          </el-radio-group>
          <el-upload
            class="avatar-uploader"
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload"
          >
            <img v-if="imageUrl" class="avatar" />
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      imageUrl: '',
      form: {
        status: ''
      }
    }
  },
  methods: {
    handleAvatarSuccess () {},
    beforeAvatarUpload () {}
  }
}
</script>

<style lang="less" scoped>
.el-input,
.el-select {
  width: 400px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
  border: 1px dashed #ccc;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
